Introduction

The One-Time Pad (OTP) or also known as the Vernam Cipher is the most famous (and perhaps the only remotely useful) perfectly secret cipher. It uses a plaintext and a key with the same length and produces a ciphertext also with that length. The mainstay of this cipher is the XOR operation. Encryption simply XORs the key with the plaintext and decryption XORs the ciphertext with the key to retrieve the plaintext.

Proof: Validity of OTP

To ensure that OTP is a valid Shannon cipher, we check the decryption function.

This indeed proves that decryption undoes encryption and so OTP is a valid private-key encryption scheme.

Proof: Perfect Secrecy of OTP

We claim that for every , the distribution obtained by sampling the keyspace and outputting is the uniform distribution over and therefore, the distributions and are identical for every .

Observe that every ciphertext is output by if and only if . This in turn is true if and only if . The key is chosen uniformly at random from , so the probability that happens to be is exactly . Moreover, the key, plaintext and ciphertext have the same length, so which means that this probability is equal to , thus making the cipher perfectly secret.

Attacks on the One-Time Pad

The One-Time Pad is indeed perfectly secret but only if the same key is never reused. If an adversary had access to two or more ciphertexts, then they could obtain information about the XOR of the two underlying plaintexts by XOR-ing the ciphertexts together.